/**
 * 
 */
package com.hjx.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hjx.dao.ArticleMapper;
import com.hjx.model.Article;
import com.hjx.model.ArticleCriteria;
import com.hjx.model.Page;
import com.hjx.service.IArticleService;

/**
 * @author huangjixin
 * 
 */

@Service(value = "articleService")
@RemotingDestination(value = "articleService",channels= {"my-amf","my-secure-amf"})
@Transactional
public class ArticleServiceImpl extends AbstractGenericService<Article, Integer> implements
		IArticleService {

	@Autowired
	private ArticleMapper articleMapper;
	


	@Override
	public List<Article> selectAll() {
		List<Article> list = articleMapper.selectByExample(new ArticleCriteria());
		return list;
	}

	@Override
	public Page selectByPage(Page page) {
		ArticleCriteria userCriteria = new ArticleCriteria();
		userCriteria.setStart(page.getStart());
		userCriteria.setLimit(page.getLimit());
		int count = articleMapper.countByExample(new ArticleCriteria());
		List<Article> list = articleMapper.selectByExample(userCriteria);
		page.setCount(count);
		page.setList(list);
		
		return page;
	}
	
	@Override
	public int deleteByPrimaryKey(Integer id) {
		int i = articleMapper.deleteByPrimaryKey(id);
		return i;
	}

	@Override
	public int insert(Article record) {
		super.insert(record);
		int i = articleMapper.insert(record);
		return i;
	}

	@Override
	public int insertSelective(Article record) {
		super.insertSelective(record);
		int i = articleMapper.insertSelective(record);
		return i;
	}

	@Override
	public Article selectByPrimaryKey(Integer id) {
		Article user = articleMapper.selectByPrimaryKey(id);
		return user;
	}

	@Override
	public int updateByPrimaryKeySelective(Article record) {
		int i = articleMapper.updateByPrimaryKeySelective(record);
		return i;
	}

	@Override
	public int updateByPrimaryKey(Article record) {
		int i = articleMapper.updateByPrimaryKey(record);
		return i;
	}

}
